var url = "http://192.168.14.49:3000/search"

function http({callback,data}){
    
    $.ajax({
        type:"get",
        url:`${url}?keywords=${data.value}&limit=${data.number}`,
        dataType:"json",
        success:res=>{
            callback(res); 
        },
        beforeSend:()=>{
            $(".main-content-box").children().remove();
        }
    })
}
function time(x){
    if(x/1000/60<=10){
      var min=('0'+Math.floor(x/1000/60))
    }else{
        min=Math.floor(x/1000/60)
    }
    
    if(x/1000%60<=10){
     var sec='0'+Math.round(x/1000%60)
    }else{
        sec=Math.round(x/1000%60)
    }
    
    return min+':'+sec;
}
function remove(){
    $(".main-content-box").children().remove();
}

function duqu(aim){
    aim.forEach((item, index) => {

               
        var alias = item.alias;
        if (item.alias == false) {
            alias = ""
        } else {
            alias = '&nbsp;- ' + item.alias;
        }
        var element = `
 
        <div class="music-box">
            <div class="music-play"></div>
            <div class="music-song">

                <div class="music-name">${item.name}</div>
                <div class="music-alias">${alias}</div>
            </div>
            <div class="music-td"></div>
            <div class="music-author">${item.artists[0].name}</div>
            <div class="music-album">${'《'+item.album.name+'》'}</div>
            <div class="music-time">${time(item.duration)}</div>
        </div>`
        $('.musics-box').append(element)
    })
}
function onReachBottom(){
    var scrollHeight=document.documentElement.scrollHeight;
    var clentHeight=document.documentElement.clentHeight;
    var scrollTop=Math.ceil(document.documentElement.scrollTop);
    console.log("到底刷新")
    return (scrollHeight==clentHeight+scrollTop)?true:false;
}
